import axios from "./axios.js"


// 登陆功能
export const userLogin = async (params) => {
    return await axios.post('/user/login', params)
}

// 注册功能
export const userRegister = async (params) => {
    return await axios.post('/user/register', params)
}

// 修改用户目标体重功能
export const changeTargetWeight = async (params) => {
    return await axios.post('/target/targetWeight', params)
}

// 修改用户当前体重功能
export const changeNowWeight = async (params) => {
    return await axios.post('/weight/changeNowWeight', params)
}

//获取最近七天的体重数据
export const getWeightData = async (time) => {
    return await axios.get('/weight/getWeightData', {
        params: {
            time
        }
    })
}

//获取用户的目标体重、目标摄入和目标消耗
export const getTargetData = async () => {
    return await axios.get('/target/getTargetData')
}

// 写入用户的目标体重、目标摄入和目标消耗
export const writeTargetData = async (params) => {
    return await axios.post('/target/writeTargetData', params)
}

// 获取一天的餐食
export const getDietData = async (time) => {
    return await axios.get('/diet/getDietData', {
        params: {
            time
        }
    })
}

// 修改目标摄入热量
export const changeTargetIntake = (params) => {
    return axios.post('/target/targetIntake', params)
}

// 修改目标消耗热量
export const changeTargetConsume = (params) => {
    return axios.post('/target/targetConsume', params)
}

// 获取食物的营养成分
export const getFoodComponent = (foodType) => {
    return axios.get('/ai/getFoodComponent', {
        params: {
            foodType
        }
    })
}

// 写入一条食物数据
export const writeFoodData = (params) => {
    return axios.post('/diet/writeFoodData', params)
}

// 删除一条食物数据
export const deleteFoodData = (id) => {
    return axios.get('/diet/deleteFoodData', {
        params: {
            id
        }
    })
}

// 请求本周的运动数据
export const getSportData = (time) => {
    return axios.get('/sport/getSportData', {
        params: {
            time
        }
    })
}

// 删除一条运动数据
export const deleteSportData = (id) => {
    return axios.get('/sport/deleteSportData', {
        params: {
            id
        }
    })
}

// 获取一项运动大概消耗多少热量
export const getSportColorie = (params) => {
    return axios.post('/ai/getSportColorie', params)
}

// 写入一条运动数据
export const writeSportData = (params) => {
    return axios.post('/sport/writeSportData', params)
}